#!/usr/bin/python3
# -*- coding: utf-8 -*-

'''
try:
    import ttk
except ImportError:
    import tkinter.ttk as ttk
'''
try:
    import Tkinter as tk  # Python 2
except ImportError:
    import tkinter as tk  # Python 3
try:
    import tkFont
except ImportError:
    import tkinter.font as tkFont


def set_font(event):
    for sel in display.curselection():
        sel_name = '"'+fonts[sel]+'" 16'
        label.config(font=sel_name)
        return

root = tk.Tk()

root.title('Tk Font List')
root.minsize(300, 500)
# root.maxsize(max_x, max_y)

fonts = list(tkFont.families())
fonts.sort()

for name in fonts:
    print(name)

label = tk.Label(root, text='Label Text, 라벨 텍스트')
label.pack(fill=tk.BOTH, expand=tk.NO, side=tk.TOP)

display = tk.Listbox(root, font='"백묵 굴림" 10')
display.pack(fill=tk.BOTH, expand=tk.YES, side=tk.LEFT)

display.bind('<<ListboxSelect>>', set_font)

scroll = tk.Scrollbar(root)
scroll.pack(side=tk.RIGHT, fill=tk.Y, expand=tk.NO)

scroll.configure(command=display.yview)
display.configure(yscrollcommand=scroll.set)


for item in fonts:
    display.insert(tk.END, item)

root.mainloop()